package com.wn.class30.service.impl;

import com.wn.class30.entity.Cupon;
import com.wn.class30.entity.CuponExample;
import com.wn.class30.mapper.CuponDao;
import com.wn.class30.service.Couponservice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CouponServiceImpl implements Couponservice {

    @Resource
    private CuponDao cuponDao;

    @Override
    public long count() {
        return cuponDao.countByExample(null);
    }

    @Override
    public List<Cupon> selectCoupons(long pageIndex, Integer num) {
        CuponExample cuponExample = new CuponExample();
        cuponExample.setOffset((pageIndex-1)*num);
        cuponExample.setLimit(num);
        return cuponDao.selectByExample(cuponExample);
    }

    @Override
    public int insertSelective(Cupon record) {
        return cuponDao.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer cuponId) {
        return cuponDao.deleteByPrimaryKey(cuponId);
    }

    @Override
    public int updateByPrimaryKeySelective(Cupon record) {
        return cuponDao.updateByPrimaryKeySelective(record);
    }


}
